package com.yazq.service.impl;

import com.yazq.mapper.DeptMapper;
import com.yazq.pojo.Dept;
import com.yazq.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;
@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
    private DeptMapper mapper;

    @Override
    public List<Dept> getDeptInfoService() {
        return mapper.getDeptInfo();
    }

    @Override
    public Integer deleteDeptService(Integer id){
        return mapper.deleteDept(id);
    }

    @Override
    public Integer addDeptService(Dept dept) {
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        return mapper.addDept(dept);
    }

    @Override
    public Integer updateDeptInfo(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        return mapper.updateDept(dept);
    }

    @Override
    public Dept getDeptInfoByIdService(Integer id) {
        return mapper.getInfoById(id);
    }
}
